import request from '@/utils/request'

export function additionRole(data) {
  return request({
    url: '/role',
    method: 'post',
    data
  })
}

export function removeRole(id) {
  return request({
    url: `/role/${id}`,
    method: 'delete'
  })
}

export function updateRole(data) {
  return request({
    url: '/role',
    method: 'put',
    data
  })
}

export function searchRole(data, pageNum, pageSize) {
  return request({
    url: '/role',
    method: 'get',
    params: Object.assign({}, data, { current: pageNum, size: pageSize })
  })
}

export function listAllRole() {
  return request({
    url: '/role/all',
    method: 'get'
  })
}

export function listRoleListByUserId(userId) {
  return request({
    url: `/user-role-relation/${userId}`,
    method: 'get'
  })
}

export function assignRole(data) {
  return request({
    url: `/user-role-relation`,
    method: 'post',
    data
  })
}
